/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_BAIR")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbBair.findAll", query = "SELECT a FROM AmTbBair a"),
    @NamedQuery(name = "AmTbBair.findByCdBair", query = "SELECT a FROM AmTbBair a WHERE a.cdBair = :cdBair"),
    @NamedQuery(name = "AmTbBair.findByNmBair", query = "SELECT a FROM AmTbBair a WHERE a.nmBair = :nmBair")})
public class AmTbBair implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_BAIR")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_BAIR")
    @SequenceGenerator(name="seq_AM_TB_BAIR", sequenceName = "seq_AM_TB_BAIR")
    private Integer cdBair;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_BAIR")
    private String nmBair;
    @JoinColumn(name = "CD_REGI", referencedColumnName = "CD_REGI")
    @ManyToOne(optional = false)
    private AmTbRegi cdRegi;
    @JoinColumn(name = "CD_CIDA", referencedColumnName = "CD_CIDA")
    @ManyToOne(optional = false)
    private AmTbCida cdCida;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdBair")
    private Collection<AmTbLogr> amTbLogrCollection;

    public AmTbBair() {
    }

    public AmTbBair(Integer cdBair) {
        this.cdBair = cdBair;
    }

    public AmTbBair(Integer cdBair, String nmBair) {
        this.cdBair = cdBair;
        this.nmBair = nmBair;
    }

    public Integer getCdBair() {
        return cdBair;
    }

    public void setCdBair(Integer cdBair) {
        this.cdBair = cdBair;
    }

    public String getNmBair() {
        return nmBair;
    }

    public void setNmBair(String nmBair) {
        this.nmBair = nmBair;
    }

    public AmTbRegi getCdRegi() {
        return cdRegi;
    }

    public void setCdRegi(AmTbRegi cdRegi) {
        this.cdRegi = cdRegi;
    }

    public AmTbCida getCdCida() {
        return cdCida;
    }

    public void setCdCida(AmTbCida cdCida) {
        this.cdCida = cdCida;
    }

    @XmlTransient
    public Collection<AmTbLogr> getAmTbLogrCollection() {
        return amTbLogrCollection;
    }

    public void setAmTbLogrCollection(Collection<AmTbLogr> amTbLogrCollection) {
        this.amTbLogrCollection = amTbLogrCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdBair != null ? cdBair.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbBair)) {
            return false;
        }
        AmTbBair other = (AmTbBair) object;
        if ((this.cdBair == null && other.cdBair != null) || (this.cdBair != null && !this.cdBair.equals(other.cdBair))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbBair[ cdBair=" + cdBair + " ]";
    }
    
}
